package com.test.io;

import java.io.PrintStream;
import java.nio.ByteBuffer;

public class GetData {

	private static final int BSIZE = 1024;
	
	public static void main(String[] args){
		ByteBuffer bb = ByteBuffer.allocate(BSIZE);
		//allocation automatically zeroes the bytebuffer
		int i =0;
		while(i++ <bb.limit()){
			if(bb.get()!=0){
				System.out.println("nonzero");
			}
			System.out.println("i= " +i);
		}
		bb.rewind();
		// store and read a char array
		bb.asCharBuffer().put("Howdy!");
		char c;
		while((c=bb.getChar())!=0){
			System.out.println(c + " ");
		}
		bb.rewind();
		// store and read a short
		bb.asIntBuffer().put(99471142);
		System.out.println(bb.getShort());
		//store and read  int,
	}
}
